ActiveAdmin
安装
1.修改gemfile
因为rails 版本4以上
一种方式安装,亲测有效,安装快
gem ‘activeadmin’, ‘~> 1.0.0.pre4’
另一种方式安装,亲测,一直卡在那儿,就没试
gem ‘activeadmin’, github: ‘activeadmin’
2.命令行安装
rails g active_admin:install
安装可能遇到问题:
- 1.Please remove gem ‘meta_search’ and try again
解决:如以上方式安装(版本问题)
- 2.Sprockets::FileNotFound: couldn’t find file ‘jquery-ui/datepicker’ after upgrade to jquery-ui-rails 6.0
解决:按提示来,然后在application.js添加
//= require jquery-ui
- 3.数据库迁移
rake db:migrate
- 4.默认账号登不上去,提示重定向
解决: 清除缓存cookie,关闭浏览器重新登录
3.管理已有model,做curd操作
rails generate active_admin:resource MyModel
汉化
1.局部汉化
|
|
2.框架汉化
1.修改config/application.rb文件,添加下面两行。
12config.i18n.available_locales = [:"zh-CN", :en]config.i18n.default_locale = :"zh-CN"2.将zh-CN.yml复制到自己的 config/locales/目录下。
:https://github.com/activeadmin/activeadmin/blob/master/config/locales/zh-CN.yml
3.继续添加在zh-CN
https://github.com/plataformatec/devise/wiki/I18n
4 可能报错
ActionView::Template::Error (translation missing: zh-CN.time.formats.long):
1: insert_tag renderer_for(:index)
app/admin/admin_user.rb:6:in `block (2 levels) in‘ 解决:zh.yml 修改如下
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310"zh-CN":active_admin:dashboard: "控制面板"dashboard_welcome:welcome: "欢迎使用Active Admin. 这是默认的控制面板页."call_to_action: "若要添加新的面板内容, 请修改 'app/admin/dashboard.rb'"view: "查看"edit: "编辑"delete: "删除"delete_confirmation: "确定删除?"new_model: "新建%{model}"edit_model: "编辑%{model}"delete_model: "删除%{model}"details: "%{model}详情"cancel: "取消"empty: "清空"previous: "上一个"next: "下一个"download: "下载:"has_many_new: "新建一个%{model}"has_many_delete: "删除"has_many_remove: "清除"filters:buttons:filter: "过滤"clear: "清除条件"predicates:contains: "包含"equals: "等于"starts_with: "开头"ends_with: "完与"greater_than: "大于"less_than: "小于"search_status:headline: "搜索条件:"current_scope: "搜索范围:"current_filters: "过滤条件:"no_current_filters: "无"status_tag:"yes": "是的""no": "无"main_content: "请执行 %{model}#main_content 来显示内容."logout: "退出"powered_by: "Powered by %{active_admin} %{version}"sidebars:filters: "所有条件"search_status: "搜索条件"pagination:empty: "暂时没有%{model}"one: "显示 <b>1</b> %{model}"one_page: "显示 <b>所有 %{n}</b> %{model}"multiple: "显示所有 <b>%{total}</b> %{model}中的<b>%{from} - %{to}</b> 条"multiple_without_total: "%{model}中的<b>%{from} - %{to}</b> 条"entry:one: "条目"other: "条目"any: "任何"blank_slate:content: "暂时还没有%{resource_name}."link: "新建一个"dropdown_actions:button_label: "行动"batch_actions:button_label: "批处理"default_confirmation: "你确定你要这样做?"delete_confirmation: "你确定要删除所有%{plural_model}?"succesfully_destroyed:one: "成功删除 1 %{model}"other: "成功删除 %{count} %{plural_model}"selection_toggle_explanation: "(切换选择)"link: "新建一个"action_label: "%{title} 被选中"labels:destroy: "删除"comments:body: "内容"author: "作者"title: "评论"add: "添加评论"resource: "资源"no_comments_yet: "暂时没有评论"title_content: "(%{count})条评论"errors:empty_text: "评论保存失败,内空不能为空."devise:username:title: "用户名"email:title: "邮箱"subdomain:title: "子域"password:title: "密码"login:title: "登录"remember_me: "记住我"submit: "登录"reset_password:title: "忘记了密码?"submit: "重置我的密码"unlock:title: "重新发送送解锁命令"submit: "重新发送送解锁命令"resend_confirmation_instructions:title: " 重新发送确认指示"submit: " 重新发送确认指示"links:sign_in: "登录"forgot_your_password: "忘记了密码?"sign_in_with_omniauth_provider: "登入%{provider}"access_denied:message: "您无权处理此操作"date:abbr_day_names:- 日- 一- 二- 三- 四- 五- 六abbr_month_names:-- 1月- 2月- 3月- 4月- 5月- 6月- 7月- 8月- 9月- 10月- 11月- 12月day_names:- 星期日- 星期一- 星期二- 星期三- 星期四- 星期五- 星期六formats:default: ! '%Y-%m-%d'long: ! '%Y年%b%d日'short: ! '%b%d日'month_names:-- 一月- 二月- 三月- 四月- 五月- 六月- 七月- 八月- 九月- 十月- 十一月- 十二月order:- :year- :month- :daydatetime:distance_in_words:about_x_hours:one: 大约一小时other: 大约 %{count} 小时about_x_months:one: 大约一个月other: 大约 %{count} 个月about_x_years:one: 大约一年other: 大约 %{count} 年almost_x_years:one: 接近一年other: 接近 %{count} 年half_a_minute: 半分钟less_than_x_minutes:one: 不到一分钟other: 不到 %{count} 分钟less_than_x_seconds:one: 不到一秒other: 不到 %{count} 秒over_x_years:one: 一年多other: ! '%{count} 年多'x_days:one: 一天other: ! '%{count} 天'x_minutes:one: 一分钟other: ! '%{count} 分钟'x_months:one: 一个月other: ! '%{count} 个月'x_seconds:one: 一秒other: ! '%{count} 秒'prompts:day: 日hour: 时minute: 分month: 月second: 秒year: 年errors: &errorsformat: ! '%{attribute} %{message}'messages:accepted: 必须是可被接受的blank: 不能为空字符confirmation: 与确认值不匹配empty: 不能留空equal_to: 必须等于 %{count}even: 必须为双数exclusion: 是保留关键字greater_than: 必须大于 %{count}greater_than_or_equal_to: 必须大于或等于 %{count}inclusion: 不包含于列表中invalid: 是无效的less_than: 必须小于 %{count}less_than_or_equal_to: 必须小于或等于 %{count}not_a_number: 不是数字not_an_integer: 必须是整数odd: 必须为单数record_invalid: ! '验证失败: %{errors}'taken: 已经被使用too_long: 过长(最长为 %{count} 个字符)too_short: 过短(最短为 %{count} 个字符)wrong_length: 长度非法(必须为 %{count} 个字符)template:body: 如下字段出现错误:header:one: 有 1 个错误发生导致「%{model}」无法被保存。other: 有 %{count} 个错误发生导致「%{model}」无法被保存。helpers:select:prompt: 请选择submit:create: 新增%{model}submit: 储存%{model}update: 更新%{model}number:currency:format:delimiter: ! ','format: ! '%u %n'precision: 2separator: .significant: falsestrip_insignificant_zeros: falseunit: CN¥format:delimiter: ! ','precision: 3separator: .significant: falsestrip_insignificant_zeros: falsehuman:decimal_units:format: ! '%n %u'units:billion: 十亿million: 百万quadrillion: 千兆thousand: 千trillion: 兆unit: ''format:delimiter: ''precision: 1significant: falsestrip_insignificant_zeros: falsestorage_units:format: ! '%n %u'units:byte:one: Byteother: Bytesgb: GBkb: KBmb: MBtb: TBpercentage:format:delimiter: ''precision:format:delimiter: ''support:array:last_word_connector: ! ', 和 'two_words_connector: ! ' 和 'words_connector: ! ', 'time:am: 上午formats:default: ! '%Y年%b%d日 %A %H:%M:%S %Z'long: ! '%Y年%b%d日 %H:%M'short: ! '%b%d日 %H:%M'pm: 下午# remove these aliases after 'activemodel' and 'activerecord' namespaces are removed from Rails repositoryactivemodel:errors:<<: *errorsactiverecord:errors:<<: *errors
富文本编辑器(http://blog.csdn.net/feng88724/article/details/49181143)
1.ckeditor(亲测有效)
1、gem 'ckeditor'
2、rails g ckeditor:install
3、rake db:migrate
4、active_admin.js里加上 //= require ckeditor/init
5、f.input [字段名], :as => :ckeditor
6、样式表中加上
|
|
2.kindeditor(failed)
s1、gem ‘rails_kindeditor’
2、rails generate rails_kindeditor:install
3、f.input [字段名], :as => :kindeditor
4、ke-Container ke-container-default
这是kindeditor自动生成的div默认类,可另加一个类,在样式表加上:
.[新加的类] {
width: 79%; //宽度根据实际情况作调整
}